<template>
	<div>
	
		
		<fieldset style="border:1px solid #DCDCDC">
		<legend style="color: #DCDCDC;">车辆信息</legend>
		
		<el-row>
			<el-col :span="1" class="labelCol">
				<p class="labelText">选择车型:</p>
			</el-col>
			<el-col :span='4'>
				<el-select size="small" v-model="queryCon.series" placeholder="请选择车型" clearable multiple>
					<el-option v-for="item in seriesCombo" :label="item.label" :value="item.value">
					</el-option>
					<el-option label='其它' value='QT'></el-option>
				</el-select>
			</el-col>
			<el-col :span="1" class="labelCol">
				<p class="labelText">快速选择:</p>
			</el-col>
			<el-col :span='4'>
				<el-select size="small" v-model="carLevel" placeholder="快速选择车型" clearable @change="changeSeries">
					<el-option v-for="item in carLevelCombo" :label="item.label" :value="item.value">
					</el-option>
				</el-select>
			</el-col>
			<el-col :span="1" class="labelCol">
				<p class="labelText">选择车龄:</p>
			</el-col>
			<el-col :span='4'>
				<el-select v-model="queryCon.age" size="small" placeholder="请选择车龄" clearable multiple>
					<el-option v-for="item in carAge" :label="item.label" :value="item.value">
					</el-option>
				</el-select>
			</el-col>
			<el-col :span="1" class="labelCol">
				<p class="labelText">选择里程:</p>
			</el-col>
			<el-col :span='4'>
				<el-select v-model="queryCon.lc" size="small" placeholder="请选择里程" clearable multiple>
					<el-option v-for="item in carLc" :label="item.label" :value="item.value">
					</el-option>
				</el-select>
			</el-col>
		</el-row>
		
		
		<el-row>

			<el-col :span="1" class="labelCol">
				<p class="labelText">行政区域:</p>
			</el-col>
			<el-col :span="4">
				<el-select size="small" v-model="queryCon.area" multiple placeholder="行政区域" clearable>
					<el-option v-for="item in  areaCombo" :label="item.label" :value="item.value"></el-option>
				</el-select>
			</el-col>

			<el-col :span="1" class="labelCol">
				<p class="labelText">车牌尾数:</p>
			</el-col>
			<el-col :span="4">
				<el-select size="small" v-model="queryCon.ws" multiple placeholder="车牌尾数" clearable>
					<el-option v-for="item in plateNumWSCombo" :label="item.label" :value="item.value"></el-option>
				</el-select>
			</el-col>
			<el-col :span="1" class="labelCol">
				<p class="labelText">车牌尾号:</p>
			</el-col>
			<el-col :span="4">
				<el-select size="small" v-model="queryCon.wh" multiple placeholder="车牌尾号" clearable>
					<el-option v-for="item in plateNumWHCombo" :label="item.label" :value="item.value"></el-option>
				</el-select>
			</el-col>
			<el-col :span="1" class="labelCol">
				<p class="labelText">维系人:</p>
			</el-col>

			<el-col :span="4">
				<el-input size="small" v-model="queryCon.wxId" style="width: 90%;" placeholder="请输入维系人姓名">
				</el-input>
			</el-col>
		</el-row>
		<el-row>
			<el-col :span="1" class="labelCol">
				<p class="labelText">销售顾问:</p>
			</el-col>
			<el-col :span="4">

				<el-input size="small" v-model="queryCon.saler" style="width: 90%;" placeholder="请输入销售顾问">
				</el-input>
			</el-col>
			<el-col :span="1" class="labelCol">
				<p class="labelText">VIN:</p>
			</el-col>
			<el-col :span="4">
				<el-input size="small" v-model="queryCon.vin" style="width: 90%;" placeholder="请输入VIN">
				</el-input>
			</el-col>
			<el-col :span="1" class="labelCol">
				<p class="labelText">市场活动:</p>
			</el-col>
			<el-col :span="4">
				<el-select size="small" v-model="queryCon.marketTag" placeholder="请选择活动" clearable>
					<el-option label="润享计划" value="润享"></el-option>
				</el-select>
			</el-col>

			<el-col :span="1" class="labelCol">
				<p class="labelText">本店购车:</p>
			</el-col>
			<el-col :span='4'>
				<el-select v-model="queryCon.fromCompany" size="small" placeholder="请选择类型" clearable>
					<el-option v-for="item in goucheCombo" :label="item.label" :value="item.value">
					</el-option>
				</el-select>
			</el-col>
		</el-row>
		
		
			

		</fieldset>
		
		<fieldset style="border:1px solid #DCDCDC">
		<legend style="color: #DCDCDC;">工单信息</legend>
		
		<el-row>

<el-col :span="1" class="labelCol">
					<p class="labelText">班组:</p>
				</el-col>
				<el-col :span='4'>
					<el-select v-model="queryCon.group" size="small" placeholder="请选择班组" clearable @change='groupChange'>
						<el-option v-for="item in dictGroupCombo" :label="item.label" :value="item.value">
						</el-option>
					</el-select>
				</el-col>


	<el-col :span="1" class="labelCol">
					<p class="labelText">一级分类:</p>
				</el-col>
				<el-col :span='4'>
					<el-select v-model="queryCon.type" size="small" placeholder="请选择一级分类" clearable @change='typeChange'>
						<el-option v-for="item in dictTypeCombo" :label="item.label" :value="item.value">
						</el-option>
					</el-select>
				</el-col>

				<el-col :span="1" class="labelCol">
					<p class="labelText">二级分类:</p>
				</el-col>
				<el-col :span='4'>
					<el-select v-model="queryCon.maintainType" size="small" placeholder="请选择二级分类" clearable>
						<el-option v-for="item in dictMaintainTypeCombo" :label="item.label" :value="item.value">
						</el-option>
					</el-select>
				</el-col>	

			<!--<el-col :span="1" class="labelCol" v-if="queryCon.balanceDate.start&&queryCon.balanceDate.end&&queryCon.workType!='索赔'">
				<p class="labelText">维修类别:</p>
			</el-col>
			<el-col :span='4' v-if="queryCon.balanceDate.start&&queryCon.balanceDate.end&&queryCon.workType!='索赔'">
				<el-select v-model="queryCon.wxType" placeholder="维修类别" size="small" clearable multiple>
					<el-option v-for="item in  wxType" :label="item.label" :value="item.value">
					</el-option>
				</el-select>
			</el-col>-->
			
			<!--<el-col :span="1" class="labelCol" v-if="queryCon.balanceDate.start&&queryCon.balanceDate.end&&queryCon.workType=='索赔'">
				<p class="labelText">索赔类别:</p>
			</el-col>
			<el-col :span='4' v-if="queryCon.balanceDate.start&&queryCon.balanceDate.end&&queryCon.workType=='索赔'">
				<el-select v-model="queryCon.wxType" placeholder="索赔类别" size="small" clearable multiple>
					<el-option v-for="item in  spTypeCombo" :label="item.label" :value="item.value">
					</el-option>
				</el-select>
			</el-col>-->
			
			<el-col :span="1" class="labelCol" v-if="queryCon.balanceDate.start&&queryCon.balanceDate.end">
				<p class="labelText">累计产值:</p>
			</el-col>
			<el-col :span='4' v-if="queryCon.balanceDate.start&&queryCon.balanceDate.end">
				<el-select v-model="queryCon.ljCz" size="small" placeholder="请选择累计产值" clearable multiple>
					<el-option v-for="item in ljcz" :label="item.label" :value="item.value">
					</el-option>
				</el-select>
			</el-col>

			
		

		</el-row>
		
		
		<el-row>

			<el-col :span="1" class="labelCol">
				<p class="labelText">开始日期:</p>
			</el-col>
			<el-col :span="4">
				<el-date-picker v-model="queryCon.balanceDate.start" size="small" type="date" :clearable="false" style="width:90%;" placeholder="工单阶段开始日期">
				</el-date-picker>
			</el-col>
			<el-col :span="1" class="labelCol">
				<p class="labelText">结束日期:</p>
			</el-col>
			<el-col :span="4">
				<el-date-picker v-model="queryCon.balanceDate.end" size="small" @change="dateChange" :clearable="false" style="width:90%;" type="date" placeholder="工单阶段结束日期">
				</el-date-picker>
			</el-col>
			<el-col :span="1" class="labelCol">
				<p class="labelText">快速选择:</p>
			</el-col>
			<el-col :span='4'>
				<el-select v-model="baCheckFlag" size="small" placeholder="快速选择工单阶段" clearable @change="dateChange">
					<el-option v-for="item in balanceComb" :label="item.label" :value="item.value">
					</el-option>
				</el-select>
			</el-col>
			
				<el-col :span="1" class="labelCol" v-if="queryCon.balanceDate.start&&queryCon.balanceDate.end">
				<p class="labelText">平均产值:</p>
			</el-col>
			<el-col :span='4' v-if="queryCon.balanceDate.start&&queryCon.balanceDate.end">
				<el-select v-model="queryCon.avgCz" size="small" placeholder="请选择平均产值" clearable multiple>
					<el-option v-for="item in avgCz" :label="item.label" :value="item.value">
					</el-option>
				</el-select>
			</el-col>
			
				
			<!--<el-col :span="1" class="labelCol" v-if="queryCon.balanceDate.start&&queryCon.balanceDate.end">
				<p class="labelText">工单类别:</p>
			</el-col>
			<el-col :span='4' v-if="queryCon.balanceDate.start&&queryCon.balanceDate.end">
				<el-select v-model="queryCon.workType" placeholder="工单类别" size="small" clearable @change="workTypeChange">
					<el-option v-for="item in  workType" :label="item.label" :value="item.value">
					</el-option>
				</el-select>
			</el-col>-->
			
			
		</el-row>
		
			<el-row>
				

			<el-col :span="1" class="labelCol" v-if="queryCon.balanceDate.start&&queryCon.balanceDate.end">
				<p class="labelText">进场次数:</p>
			</el-col>
			<el-col :span='4' v-if="queryCon.balanceDate.start&&queryCon.balanceDate.end">
				<el-select v-model="queryCon.jc" placeholder="请选择进厂次数" size="small" clearable multiple>
					<el-option v-for="item in jc" :label="item.label" :value="item.value">
					</el-option>
				</el-select>
			</el-col>
				
				
				<el-col :span="1" class="labelCol" v-if="queryCon.balanceDate.start&&queryCon.balanceDate.end">
				<p class="labelText">质保类别:</p>
			</el-col>
			<el-col :span='4' v-if="queryCon.balanceDate.start&&queryCon.balanceDate.end">
				<el-select v-model="queryCon.zbStatus" placeholder="质保状态类别" size="small" clearable>
					<el-option v-for="item in  ybStatus" :label="item.label" :value="item.value">
					</el-option>
				</el-select>
			</el-col>
			<el-col :span="1" class="labelCol" v-if="queryCon.balanceDate.start&&queryCon.balanceDate.end">
				<p class="labelText">保险类别:</p>
			</el-col>
			<el-col :span='4' v-if="queryCon.balanceDate.start&&queryCon.balanceDate.end">
				<el-select v-model="queryCon.bx" placeholder="保险类别" size="small" clearable multiple>
					<el-option v-for="item in  bxType" :label="item.label" :value="item.value">
					</el-option>
				</el-select>
			</el-col>
			
			
			</el-row>
			
			
			
		
		<el-row>
			
			<el-col :span="1" class="labelCol" v-if="queryCon.balanceDate.start&&queryCon.balanceDate.end&&queryCon.zbStatus ">
				<p class="labelText">延保类别:</p>
			</el-col>
			<el-col :span='4' v-if="queryCon.balanceDate.start&&queryCon.balanceDate.end&&queryCon.zbStatus">
				<el-select v-model="queryCon.ybType" placeholder="延保类别" size="small" clearable multiple>
					<el-option v-for="item in  ybType" :label="item.label" :value="item.value">
					</el-option>
				</el-select>
			</el-col>
			<el-col :span="1" class="labelCol" v-if="queryCon.balanceDate.start&&queryCon.balanceDate.end&&queryCon.bx.length">
				<p class="labelText">保险项目:</p>
			</el-col>
			<el-col :span='4' v-if="queryCon.balanceDate.start&&queryCon.balanceDate.end&&queryCon.bx.length">
				<el-select v-model="queryCon.bxItem" placeholder="保险项目" size="small" clearable multiple>
					<el-option v-for="item in  bxItemCombo" :label="item.label" :value="item.value">
					</el-option>
				</el-select>
			</el-col>
		</el-row>
			
		</fieldset>
		
			<fieldset style="border:1px solid #DCDCDC">
			<legend style="color: #DCDCDC;">车主信息</legend>
		
			
			<el-row>

				<el-col :span="1" class="labelCol">
					<p class="labelText">车主年龄:</p>
				</el-col>
				<el-col :span='4'>
					<el-select v-model="queryCon.ownerOld" size="small" placeholder="请选择" clearable multiple>
						<el-option v-for="item in ownerOldCombo" :label="item.label" :value="item.value">
						</el-option>
					</el-select>
				</el-col>

				<el-col :span="1" class="labelCol">
					<p class="labelText">车主性别:</p>
				</el-col>
				<el-col :span='4'>
					<el-select v-model="queryCon.ownerGender" size="small" placeholder="请选择" clearable>
						<el-option v-for="item in ownerGenderCombo" :label="item.label" :value="item.value">
						</el-option>
					</el-select>
				</el-col>

			</el-row>
			
			
		</fieldset>
		
		
		</fieldset>
			<fieldset style="border:1px solid #DCDCDC">
			<legend style="color: #DCDCDC;">卡信息</legend>
			<el-row>
				<el-col :span="1" class="labelCol">
					<p class="labelText">卡类型:</p>
				</el-col>
				<el-col :span='4'>
					<el-select v-model="queryCon.cardType" size="small" placeholder="请选择" clearable>
						<el-option v-for="item in cardTypeCombo" :label="item.label" :value="item.value">
						</el-option>
					</el-select>
				</el-col>

				<el-col :span="1" class="labelCol">
					<p class="labelText">卡剩余:</p>
				</el-col>
				<el-col :span='2'>
				<el-input size="small" v-model="queryCon.cardValueStart" placeholder="最小值"></el-input>
				</el-col>
				<el-col :span='2'>
				<el-input size="small" v-model="queryCon.cardValueEnd" placeholder="最大值"></el-input>
				</el-col>
				
				<el-col :span="1" class="labelCol">
					<p class="labelText">卡项目:</p>
				</el-col>
				<el-col :span='4'>
					<el-select v-model="queryCon.cardItem" size="small" placeholder="请选择" clearable>
						<el-option v-for="item in cardItemCombo" :label="item.label" :value="item.value">
						</el-option>
					</el-select>
				</el-col>
				
				
			</el-row>
		</fieldset>
		
		<el-row>
			<el-col :span="4" style="float:right">
				<el-button type="primary" size="small" v-on:click='queryZhCar'>查询</el-button>

				<el-button type="primary" size="small" v-on:click='creatTask'>生成任务</el-button>

				<el-button type="primary" size="small" v-on:click='baseComOut' v-if="btnGroup.out">导出</el-button>
			</el-col>
		</el-row>
		
		

		<el-row>

			<el-col :span="24">
				<el-table :data="carGrid.dataList" stripe border height="460" v-loading.body="loading" element-loading-text="正在加载，请稍候..." @selection-change="handleSelectionChange">
					<el-table-column type="selection" width="55" fixed>
					</el-table-column>

					<el-table-column prop="plateNum" label="车牌号" width="110">
					</el-table-column>
					<el-table-column prop="active" label="活跃等级" width="110">
					</el-table-column>
					<el-table-column prop="series" label="车型" width="160">
					</el-table-column>
					<el-table-column prop="ownerName" width="120" label="车主">
					</el-table-column>
					<el-table-column prop="carAge" label="车龄" align="right" width="70">
					</el-table-column>
					<el-table-column prop="ownerCity" label="地区" width="150">
					</el-table-column>
					<el-table-column prop="mCz" label="月产值" align="right" width="100" :formatter="fixedmCz">
					</el-table-column>
					<el-table-column prop="ljcz" label="累计产值" align="right" width="100" :formatter="fixedLjcz">
					</el-table-column>
					<el-table-column prop="avgCz" label="平均产值" align="right" width="100" :formatter="fixedAvgCz">
					</el-table-column>

					<el-table-column prop="jccs" label="进厂" align="right" width="70">
					</el-table-column>

					<el-table-column prop="firsEnterDate" label="首次进厂日期" align="center" width="120" :formatter="eTimeForm">
					</el-table-column>
					<el-table-column prop="lastEnterDate" label="最后进厂日期" align="center" width="120" :formatter="fTimeForm">
					</el-table-column>
					<el-table-column prop="vin" label="VIN" width="180">
					</el-table-column>
					<el-table-column prop="fromCompany" label="本店购车" width="100">
					</el-table-column>
					<el-table-column prop="runMile" label="里程" align="right" width="110">
					</el-table-column>
					
					<el-table-column prop="item" label="卡项目" align="right" width="110">
					</el-table-column>
					<el-table-column prop="cardType" label="卡类别" align="right" width="110">
					</el-table-column>
					<el-table-column prop="value" label="卡剩余值" align="right" width="110">
					</el-table-column>
					
				</el-table>
				<el-pagination small @current-change="pageChange" :current-page="curPage" :page-sizes="page.pageSizes" :page-size="page.pageSize" layout=" total,prev, pager, next" :total="carGrid.total">
				</el-pagination>
			</el-col>

		</el-row>
		<el-dialog title="生成任务" v-model="creatTaskShow" size="tiny">
			<el-form :model="creatTaksData" ref="creatTaskForms" :rules="creattaskRule" label-width="100px">
				<el-col :span="24">
					<el-form-item label="提醒时间:" prop="exptDate">
						<el-date-picker v-model="creatTaksData.exptDate" type="date" placeholder="选择日期" format="yyyy-MM-dd"></el-date-picker>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="任务大类:" prop="taskPtype">
						<el-select v-model="creatTaksData.taskPtype" size='small' placeholder="任务大类" @change="taskStatusChange">
							<el-option v-for="item in  taskPTypeCombo" :label="item.label" :value="item.value">
							</el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="任务小类:" prop="taskCtype">
						<el-select v-model="creatTaksData.taskCtype" size='small' placeholder="任务细类" clearable>
							<el-option v-for="item in  taskCTypeCombo" :label="item.label" :value="item.value">
							</el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<el-col :span="24" v-if="creatTaksData.taskCtype == 'zdy'">
					<el-form-item label="提示内容:" prop="title">
						<el-input size="small" type="textarea" autosize="{ minRows: 2, maxRows: 4}" v-model="creatTaksData.title" placeholder="请输入提醒内容以便生成任务"></el-input>
					</el-form-item>
				</el-col>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button @click="creatTaskShow = false">取 消</el-button>
				<el-button type="primary" @click="save">提 交</el-button>
			</div>
		</el-dialog>
	</div>
</template>
<script>
	import moment from 'moment'
	export default {
		// 基本数据
		data: function() {
			return {
				area: '',
				brand: '',
				companyId: window.localStorage.getItem("companyId"),
				areaCombo2: [],
				brandCombo: [],
				companyCombo: [],
				//索赔类别
				spTypeCombo: [],
				//复选框选择数据
				multipleSelection: [],
				//生成任务显示
				creatTaskShow: false,
				//生成任务：
				creatTaksData: {
					exptDate: '',
					taskPtype: '',
					taskCtype: '',
					title: '',
				},
				emptyTaksData: {
					exptDate: '',
					taskPtype: '',
					taskCtype: '',
					title: '',
				},
				//生成任务规则
				creattaskRule: {
					taskPtype: [{
						required: true,
						message: '请选择任务大类',
						trigger: 'change'
					}],
					taskCtype: [{
						required: true,
						message: '请选择任务小类',
						trigger: 'change'
					}],
					exptDate: [{
						type: 'date',
						required: true,
						message: '请选择提醒日期',
						trigger: 'blur'
					}],
				},
				//任务大类
				taskPTypeCombo: [{
					value: 'by',
					label: '保养'
				}, {
					value: 'bx',
					label: '保险'
				}, {
					value: 'ls',
					label: '流失'
				}, {
					value: 'ga',
					label: '关爱'
				}, {
					value: 'qt',
					label: '其他'
				}],
				//任务小类
				taskCTypeCombo: [],
				//任务状态
				bxChild: [{
					value: 'cnj',
					label: '次年交强险'
				}, {
					value: 'cns',
					label: '次年商业险'
				}, {
					value: 'xbj',
					label: '交强险续保'
				}, {
					value: 'xbs',
					label: '商业险续保'
				}, {
					value: 'hyt',
					label: '保险活跃'
				}, {
					value: 'fhyt',
					label: '保险非活跃'
				}, {
					value: 'jdj',
					label: '交强险接待'
				}, {
					value: 'jds',
					label: '商业险接待'
				}],
				gaChild: [{
					value: 'sr',
					label: '生日'
				}, {
					value: 'ns',
					label: '年审'
				}, {
					value: 'zbt',
					label: '质保'
				}, {
					value: 'ybt',
					label: '延保'
				}],
				zdyChild: [{
					value: 'zdy',
					label: '自定义'
				}],
				lsChild: [{
						value: '6',
						label: '六个月'
					}, {
						value: '7',
						label: '七个月'
					}, {
						value: '8',
						label: '八个月'
					}, {
						value: '9',
						label: '九个月'
					},
					{
						value: '10',
						label: '十个月'
					},
					{
						value: '11',
						label: '十一个月'
					},
					{
						value: '12',
						label: '十二个月'
					}
				],

				//任务状态
				byChild: [{
					value: 'sy_mbr',
					label: '新车首月'
				}, {
					value: 'sb_mbr',
					label: '首保'
				}, {
					value: 'sb_mby',
					label: ' 首保月'
				}, {
					value: 'eb_mbr',
					label: '二保'
				}, {
					value: 'eb_mby',
					label: '二保月'
				}, {
					value: 'db_mbr',
					label: '定保'
				}, {
					value: 'db_mby',
					label: '定保月'
				}],

				carLevelCombo: [],
				//车型
				seriesCombo: [],
				//车龄
				carAge: [],
				//里程
				carLc: [],
				bxItemCombo: [],
				areaCombo: [],
				goucheCombo: [{
					label: '是',
					value: '1'
				}, {
					label: '否',
					value: '0'
				}, ],
				//工单阶段快速选择
				balanceComb: [{
					label: '一月内',
					value: 1
				}, {
					label: '三月内',
					value: 3
				}, {
					label: '半年内',
					value: 6
				}, {
					label: '一年内',
					value: 12
				}, {
					label: '两年内',
					value: 24
				}, {
					label: '三年内',
					value: 36
				}],
				ljcz: [{
						label: '10-1000',
						value: '10-1000'
					}, {
						label: '1001-3000',
						value: '1001-3000'
					},

					{
						label: '3001-5000',
						value: '3001-5000'
					}, {
						label: '5001-10000',
						value: '5001-10000'
					}, {
						label: '10001-15000',
						value: '10001-15000'
					},

					{
						label: '15001-30000',
						value: '15001-30000'
					},

					{
						label: '30001-50000',
						value: '30001-50000'
					}, {
						label: '50000以上',
						value: '50001-500000000000'
					},
				],
				avgCz: [{
					label: '10-1000',
					value: '10-1000'
				}, {
					label: '1001-2000',
					value: '1001-2000'
				}, {
					label: '2001-3000',
					value: '2001-3000'
				}, {
					label: '3001-5000',
					value: '3001-5000'
				}, {
					label: '5000以上',
					value: '5001-500000000000'
				}, ],
				jc: [{
						label: '1次',
						value: 1
					}, {
						label: '2次',
						value: 2
					}, {
						label: '3次',
						value: 3
					}, {
						label: '4次',
						value: 4
					}, {
						label: '5次',
						value: 5
					}, {
						label: '6次',
						value: 6
					}, {
						label: '7次',
						value: 7
					}, {
						label: '8次',
						value: 8
					}, {
						label: '8次以上',
						value: 9
					},

				],
				workType: [{
					label: '维修',
					value: '维修'
				}, {
					label: '索赔',
					value: '索赔'
				}, ],
				//
				wxType: [{
					label: '首保',
					value: '首保'
				}, {
					label: '二保',
					value: '二保'
				}, {
					label: '定保',
					value: '定保'
				}, {
					label: '一般维修',
					value: '一般维修'
				}, {
					label: '事故车',
					value: '事故车'
				}, ],
				ybType: [],

				bxType: [{
					label: '新保',
					value: '0'
				}, {
					label: '续保',
					value: '1'
				}, ],

				ybStatus: [{
						label: '在质保',
						value: '0'
					}, {
						label: '在延保',
						value: '1'
					}, {
						label: '已出保',
						value: '2'
					},

				],
				baCheckFlag: '',
				dictGroupCombo: [],
				dictTypeCombo: [],
				dictMaintainTypeCombo: [],
				ownerGenderCombo:[
				{label:'男',value:'1'},{label:'女',value:'0'}],
				
				cardItemCombo:[
				{label:'洗车',value:'洗车'},
				{label:'外饰套餐',value:'外饰'},
				{label:'内饰套餐',value:'内饰'},
				{label:'全年免费补胎',value:'全年免费补胎'},
				{label:'臭氧消毒',value:'臭氧消毒'},
				{label:'打蜡',value:'打蜡'},
				{label:'镀晶',value:'镀晶'},
				{label:'保养金卡',value:'保养金卡'},
				{label:'精品封釉',value:'精品封釉'},
				{label:'漆面',value:'漆面'},
				{label:'抛光',value:'抛光'},
				{label:'轮毂',value:'轮毂'},
				{label:'四轮换位',value:'四轮换位'},
				{label:'赠送账户',value:'赠送账户'},
				{label:'余额',value:'余额'},
				],
				
				
				ownerOldCombo:[
				{
						label: '18-25',
						value: '1'
					}, {
						label: '26-30',
						value: '2'
					}, {
						label: '31-35',
						value: '3'
					},
					 {
						label: '36-40',
						value: '4'
					},
					 {
						label: '40以上',
						value: '5'
					},
				],
				cardTypeCombo:[
				{
						label: '美车卡',
						value: '美车卡'
					}, {
						label: '贵宾卡',
						value: '贵宾卡'
					}
				],
				
				//查询条件
				queryCon: {
					
					cardType:'', // 卡类型
					cardValueStart:'',// 卡剩余起始值
					cardValueEnd:'',// 卡剩余结束值
					cardItem:'',// 卡项目

					group: '', // 班组
					type: '', // 一级分类	
					maintainType: '', // 二级分类
					ownerOld: [], // 车主年龄
					ownerGender: '', // 车主性别
					docDate: '', // 建档日期
					lsCustomer: '', // 流失客户
					hyCustomer: '', // 活跃客户
					containsWash: '', // 是否包含洗车 0不包含 1包含

					oAreaL: '',
					brand: '',
					companyId: window.localStorage.getItem("companyId"),
					fromCompany: '',
					series: [],
					age: [],
					lc: [],
					balanceDate: {
						start: moment().add('month', -1).add(+1, "days"),
						end: new Date(),
					},
					ljCz: [],
					avgCz: [],
					jc: [],
					workType: '',
					wxType: [],
					ybType: [],
					zbStatus: '',
					bx: [],
					bxItem: [],
					area: [],
					vin: '',
					ws: [],
					wh: [],
					/*新增维系人和销售顾问 */
					wxId: "",
					saler: "",
					marketTag: "",
				},
				carLevel: '',
				carGrid: {
					total: 0,
					dataList: []
				},
				page: this.page,
				curPage: 1,
				loading: false,
				value: '',
				loadingVue: null,
				btnGroup: {},
				//车尾数
				plateNumWSCombo: [],
				//车牌尾号
				plateNumWHCombo: [],
			}

		},
		methods: {

			//工单类型改变
			workTypeChange: function() {
				this.$data.queryCon.spType = '';
				this.$data.queryCon.wxType = [];
			},

			//月产值保留两位小数
			fixedmCz: function(row, column) {
				return Number(row.mCz).toFixed(2);
			},
			//累计产值保留两位小数
			fixedLjcz: function(row, column) {
				return Number(row.ljcz).toFixed(2);
			},
			//平均产值保留两位小数
			fixedAvgCz: function(row, column) {
				return Number(row.avgCz).toFixed(2);
			},

			//复选框
			handleSelectionChange: function(val) {
				this.$data.multipleSelection = val;
			},
			/**************任务状态转换****************/
			taskStatusChange: function(value) {

				switch(value) {
					case "by":
						this.$data.taskCTypeCombo = this.$data.byChild;
						this.$data.creatTaksData.taskCtype = this.$data.taskCTypeCombo[0].value;
						break
					case "bx":
						this.$data.taskCTypeCombo = this.$data.bxChild;
						this.$data.creatTaksData.taskCtype = this.$data.taskCTypeCombo[0].value;
						break
					case "ls":
						this.$data.taskCTypeCombo = this.$data.lsChild;
						this.$data.creatTaksData.taskCtype = this.$data.taskCTypeCombo[0].value;
						break
					case "ga":
						this.$data.taskCTypeCombo = this.$data.gaChild;
						this.$data.creatTaksData.taskCtype = this.$data.taskCTypeCombo[0].value;
						break
					case "qt":
						this.$data.taskCTypeCombo = this.$data.zdyChild;
						this.$data.creatTaksData.taskCtype = this.$data.taskCTypeCombo[0].value;
						break
					default:
						this.$data.taskCTypeCombo = [];
						this.$data.creatTaksData.taskCtype = '';
						break
				}

			},
			//工单结束日期触发方法
			dateChange: function() {

				var end = this.$data.queryCon.balanceDate.end;
				//工单结束日期
				if(end) {
					if(this.$data.baCheckFlag) {
						this.$data.queryCon.balanceDate.start = new Date(this.moment(end).add(-this.$data.baCheckFlag, "month").add(+1, "day"))
					} else {
						this.$data.queryCon.balanceDate.start = new Date(this.moment(end).add(-1, "month").add(+1, "day"))
					}
				} else {
					this.$data.queryCon.balanceDate.start = '';
				}

			},
			pageChange: function(change) {
				this.$data.curPage = change;
				this.queryZhCar();
			},

			groupChange: function() {
				this.$data.dictTypeCombo = [];
				this.$data.queryCon.type = '';
				this.getBzType(this.$data.queryCon.group);
			},
			typeChange: function() {
				this.$data.dictMaintainTypeCombo = [];
				this.$data.queryCon.maintainType = '';
				this.getBzMaintainType(this.$data.queryCon.type);
			},
			getBzType: function(code) {
				this.$http.get(this.API_ROOT + '/base/dict/combo', {
					params: {
						group: code
					}
				}).then((response) => {
					this.$data.dictTypeCombo = response.data;
				}, (response) => {});
			},
			getBzMaintainType: function(code) {
				this.$http.get(this.API_ROOT + '/base/dict/combo', {
					params: {
						group: code
					}
				}).then((response) => {
					this.$data.dictMaintainTypeCombo = response.data;
				}, (response) => {});
			},

			//组合查询
			queryZhCar: function() {

				var data = {};
				this.$data.queryCon.oArea = this.$data.area;
				this.$data.queryCon.brand = this.$data.brand;
				this.$data.queryCon.companyId = this.$data.companyId;
				data = Object.assign(data, this.$data.queryCon);
				if(data.balanceDate.start) {
					data.balanceDate.start = this.moment(data.balanceDate.start).format("YYYY-MM-DD");
				}
				if(data.balanceDate.end) {
					data.balanceDate.end = this.moment(data.balanceDate.end).format("YYYY-MM-DD");
				}
				if(this.$data.companyId == "") {
					this.$message.error("请选择公司！");
				} else {

					this.$data.loading = true;
					this.$http({
						method: 'POST',
						url: this.API_ROOT + '/crm/car/zh/page',
						body: data,
						params: {
							start: this.$data.curPage,
							limit: this.$data.page.pageSize,
						}
					}).then(function(resp) {
						this.$data.loading = false;

						if(!resp.data.success) {
							this.$message.error(resp.data.msg);
							return;
						}
						debugger;
						resp.data.total = Number(resp.data.total);
						this.$data.carGrid = resp.data;
					}, function(error) {
						// error
					})
				}
			},
			//组合查询导出
			baseComOut: function() {

				var data = {};
				data = Object.assign(data, this.$data.queryCon);
				if(data.balanceDate.start) {
					data.balanceDate.start = this.moment(data.balanceDate.start).format("YYYY-MM-DD");
				}
				if(data.balanceDate.end) {
					data.balanceDate.end = this.moment(data.balanceDate.end).format("YYYY-MM-DD");
				}
				//				this.$data.loading = true;

				//				this.$http.post(this.API_ROOT + '/crm/car/zh/exportExecl', data)
				//					.then(resp => {
				//						window.location.href = this.API_ROOT + '/downlocal/' + resp.data.data + ".xlsx"
				//					}, resp => {});\n
				this.$http.post(this.API_ROOT + '/crm/car/zh/exportExecl', data, {
						params: {
							start: this.$data.CurentPage,
							limit: this.page.pageSize
						}
					})
					.then(resp => {
						if(resp.data.success) {

							window.location.href = this.API_ROOT + "/base/exp/xlsx?fileId=" + resp.data.data + "&&fileName=组合查询数据-" + this.moment().format("YYYYMMDDHHmmss") + "&&fileType=xlsx";
						}
					}, resp => {});
			},
			//生成任务按钮
			creatTask: function() {
				this.$data.creatTaskShow = true;
				this.$data.creatTaksData = Object.assign(this.$data.creatTaksData, this.$data.emptyTaksData);
			},
			//生成任务保存
			save: function() {

				if(this.$data.multipleSelection.length != 0) {
					if(this.$data.creatTaksData.title.length <= 50) {
						this.$refs.creatTaskForms.validate(function(valid) {

							var data = new Array();
							data[0] = this.$data.multipleSelection;
							data[1] = this.$data.queryCon;
							if(this.$data.creatTaksData.exptDate == '' || this.$data.creatTaksData.exptDate == null) {
								this.$data.creatTaksData.exptDate = '';
								this.$message("请选择提醒日期!");
								return;
							} else {
								this.$data.creatTaksData.exptDate = this.moment(this.$data.creatTaksData.exptDate).format("YYYY-MM-DD");
							}
							this.$data.loadingVue = this.$loading({
								fullscreen: true,
								text: "正在导入数据，请稍候"
							});
							this.$http({
									method: 'post',
									url: this.API_ROOT + '/crm/task/createZhTask',
									body: data,
									params: {
										expectDate: this.$data.creatTaksData.exptDate,
										pcode: this.$data.creatTaksData.taskPtype,
										code: this.$data.creatTaksData.taskCtype,
										title: this.$data.creatTaksData.title,
									}
								})
								.then(resp => {
									if(resp.data.success) {
										this.$message(resp.data.msg);
										this.queryZhCar();
										this.$data.creatTaskShow = false;
										this.$data.loadingVue.close();
									} else {

										this.$message.error(resp.data.msg);
										this.$data.loadingVue.close();
									}
								}, resp => {

								});
							return false;
						}.bind(this));
					} else {
						this.$message.error("您输入的提醒内容过长！")
					}

				} else {
					if(this.$data.creatTaksData.title.length <= 50) {
						this.$refs.creatTaskForms.validate(function(valid) {
							var data = new Array();
							data[0] = this.$data.multipleSelection;
							data[1] = this.$data.queryCon;
							if(this.$data.creatTaksData.exptDate == '' || this.$data.creatTaksData.exptDate == null) {
								this.$data.creatTaksData.exptDate = '';
								this.$message("请选择提醒日期!");
								return;
							} else {
								this.$data.creatTaksData.exptDate = this.moment(this.$data.creatTaksData.exptDate).format("YYYY-MM-DD");
							}
							this.$confirm('确认将查询出的全部车辆生成此任务?', '提示', {
								confirmButtonText: '确定',
								cancelButtonText: '取消',
								type: 'warning'
							}).then(() => {

								this.$data.loadingVue = this.$loading({
									fullscreen: true,
									text: "正在导入数据，请稍候"
								});
								this.$http({
										method: 'post',
										url: this.API_ROOT + '/crm/task/createZhTask',
										body: data,
										params: {
											expectDate: this.$data.creatTaksData.exptDate,
											pcode: this.$data.creatTaksData.taskPtype,
											code: this.$data.creatTaksData.taskCtype,
											title: this.$data.creatTaksData.title,
										}
									})
									.then(resp => {
										if(resp.data.success) {
											this.$message(resp.data.msg);
											this.queryZhCar();
											this.$data.creatTaskShow = false;
											this.$data.loadingVue.close();
										} else {

											this.$message.error(resp.data.msg);
											this.$data.loadingVue.close();
										}
									}, resp => {

									});

							}).catch(() => {
								this.$message({
									type: 'info',
									message: '已取消此操作'
								});
							});

						}.bind(this));
					} else {
						this.$message.error("您输入的提醒内容过长！")
					}
				}
			},

			//快速计算工单阶段日期
			setBlaceDate: function(val) {

				if(!this.$data.queryCon.balanceDate.end) {
					this.$data.queryCon.balanceDate.end = new Date();
				}

				this.$data.queryCon.balanceDate.start = moment(this.$data.queryCon.balanceDate.end).subtract('month', val).add("days", -1);

			},
			resetStartDate: function(date) {
				this.$data.baCheckFlag = '';
			},
			resetEndDate: function(date) {
				this.$data.baCheckFlag = '';
			},
			eTimeForm: function(row) {
				if(row.firsEnterDate == "" || row.firsEnterDate == null) return "";
				return moment(Number(row.firsEnterDate)).format("YYYY-MM-DD");
			},
			fTimeForm: function(row) {
				if(row.lastEnterDate == "" || row.lastEnterDate == null) return "";
				return moment(Number(row.lastEnterDate)).format("YYYY-MM-DD");
			},
			changeSeries: function(level) {
				//获取车型
				var i = 0;
				if(this.$data.carLevel == '') {
					this.$http.get(this.API_ROOT + '/base/car/combo', {
						params: {
							companyId: this.$data.companyId
						}
					}).then((response) => {
						this.$data.seriesCombo = response.data;
						this.$data.queryCon.series = [];
					}, (response) => {});
				} else {
					this.$data.queryCon.series = [];
					this.$http.get(this.API_ROOT + '/base/car/queryByLevel', {
						params: {
							level: level
						}
					}).then((response) => {

						this.$data.seriesCombo = response.data;
					}, (response) => {});
				}
			},

			getAreaCombo: function() {
				debugger;
				//加载行政区划
				//获取车型
				this.changeSeries();
				this.$data.queryCon.area = [];
				this.$data.areaCombo = [];
				this.$http.get(this.API_ROOT + '/car/base/areaCombo', {
					params: {
						companyId: this.$data.companyId,

					}
				}).then((response) => {
					debugger;
					// success callback
					this.$data.areaCombo = response.data;
				}, (response) => {
					// error callback
				});
			},
		},
		created: function() {

			//获取班组
			this.$http.get(this.API_ROOT + '/base/dict/combo', {
				params: {
					group: "bz"
				}
			}).then((response) => {
				this.$data.dictGroupCombo = response.data;
			}, (response) => {});

			//获取车型
			this.$http.get(this.API_ROOT + '/base/car/combo', {
				params: {}
			}).then((response) => {

				this.$data.seriesCombo = response.data;
			}, (response) => {});

			//获取车龄
			this.$http.get(this.API_ROOT + '/base/dict/combo', {
				params: {
					group: "02030101"
				}
			}).then((response) => {
				this.$data.carAge = response.data;
			}, (response) => {});

			//获取保险项目
			this.$http.get(this.API_ROOT + '/base/dict/combo', {
				params: {
					group: "02030109"
				}
			}).then((response) => {
				this.$data.bxItemCombo = response.data;
			}, (response) => {});

			//获取里程
			this.$http.get(this.API_ROOT + '/base/dict/combo', {
				params: {
					group: "02030105"
				}
			}).then((response) => {
				this.$data.carLc = response.data;
			}, (response) => {});

			//快速选择车型
			this.$http.get(this.API_ROOT + '/base/dict/combo', {
				params: {
					group: "0501"
				}
			}).then((response) => {
				this.$data.carLevelCombo = response.data;
			}, (response) => {});

			//		this.queryZhCar();
			//延保类型
			this.$http.get(this.API_ROOT + '/base/dict/combo', {
				params: {
					group: "020102"
				}
			}).then((response) => {
				this.$data.ybType = response.data;
			}, (response) => {});
			//索赔类别
			this.$http.get(this.API_ROOT + '/base/dict/combo', {
				params: {
					group: "02030111"
				}
			}).then((response) => {
				this.$data.spTypeCombo = response.data;
			}, (response) => {});

			//车尾数
			this.$http.get(this.API_ROOT + '/base/dict/combo', {
				params: {
					group: "02030102"
				}
			}).then((response) => {
				this.$data.plateNumWSCombo = response.data;
			}, (response) => {});

			//车尾号
			this.$http.get(this.API_ROOT + '/base/dict/combo', {
				params: {
					group: "02030103"
				}
			}).then((response) => {
				this.$data.plateNumWHCombo = response.data;
			}, (response) => {});

			//配
			this.$http({
				method: 'GET',
				url: this.API_ROOT + '/rbac/login/btn', //url 输出 按照车牌号的 车牌号
				params: { //发送的参数
					resPath: "crm/customer/carzh", //
				}
			}).then(function(resp) {
				var btnData = resp.data.dataList;

				var temp = {};

				for(var i = 0; i < btnData.length; i++) {

					var btnName = btnData[i].btnName;

					temp[btnName] = true;

				}

				Object.assign(this.$data.btnGroup, temp);
			}, function(error) {
				// error
			})

		}
	}
</script>